package com.xxl.sodmall.ui

import android.app.Activity
import android.text.TextUtils
import com.dgshanger.sanhxiaofeisc.R
import com.dgshanger.sanhxiaofeisc.mvp.contract.RegisterContract
import com.xx.baseuilibrary.mvp.BaseMvpActivity
import com.xxl.sodmall.mvp.presenter.RegisterPresenter
import kotlinx.android.synthetic.main.activity_register.*


/**
 * RegisterActivity
 * 沉迷学习不能自拔
 * Describe：注册页
 * Created by 雷小星🍀 on 2018/2/1 17:59.
 */
class RegisterActivity : BaseMvpActivity<RegisterContract.Model, RegisterContract.View, RegisterPresenter>(), RegisterContract.View {


    override fun setSendBtnEnable(enable: Boolean) {
        tv_send_code.isEnabled = enable
    }

    override fun setSendBtnText(text: String) {
        tv_send_code.text = text
    }

    override fun registerSuccess() {
        setResult(Activity.RESULT_OK)
        finish()
    }

    override fun createPresenter(): RegisterPresenter = RegisterPresenter()

    override fun getPhone(): String = et_phone.text.toString()

    override fun geteVCode(): String = et_code.text.toString()

    override fun getPassword(): String = et_password.text.toString()

    override fun getSurePassword(): String = et_newPassword.text.toString()

    override fun getRegisterReferrer(): String = et_Icode.text.toString()

    override fun getActivityLayoutId(): Int = R.layout.activity_register

    override fun initEvent() {
        ib_back.setOnClickListener { finish() }
        btn_sure.setOnClickListener { getPresenter().register() }
        tv_send_code.setOnClickListener { getPresenter().sendVCode() }
    }

    override fun initData() {
        if (TextUtils.isEmpty(getTag())) {
            //空tag,注册
//            tv_title.text = "注册"
        } else {
            //完善资料
//            tv_title.text = "完善资料"
        }
    }

    override fun getTag() = intent.getStringExtra("tag")

}